//
//  ZCRedCell.m
//  zctx
//
//  Created by apple on 16/1/22.
//  Copyright © 2016年 sanliang. All rights reserved.
//

#import "ZCRedCell.h"

@implementation ZCRedCell

- (void)awakeFromNib {
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.backgroundColor =[UIColor colorWithHexString:@"#fafcfb"];
    self.titleLable.textColor = [UIColor colorWithHexString:@"#404040"];
    self.contentLable.textColor = [UIColor colorWithHexString:@"#8a8a8a"];
    self.timeLable.textColor = [UIColor colorWithHexString:@"#8a8a8a"];
    self.moneyLable.textColor = [UIColor colorWithHexString:@"#f8a00a"];
    
}

-(void)setRedpackModel:(ZCRedpackModelContent *)redpackModel{
    _redpackModel = redpackModel;
    
    int ctimeInt =[redpackModel.ctime intValue];
    NSString *ctimeStr = [NSString stringWithFormat:@"%@",dateTimeWithNString(ctimeInt)];
    
    int etimeInt =[redpackModel.etime intValue];
    NSString *etimeStr = [NSString stringWithFormat:@"%@",dateTimeWithNString(etimeInt)];
    
    NSInteger moneyInt = [redpackModel.cash integerValue];
    NSInteger colorRange = 0;
    NSInteger total = moneyInt;
    if (total>=0 && total<10) {
        colorRange = 1;
    }else if (total>=10 && total<100){
        colorRange = 2;
    }else if (total>=100 && total<1000){
        colorRange = 3;
    }
    if (total == 0) {
        self.moneyLable.text = @"";
        self.moneyLable.hidden = YES;
    }else{
        NSString *moneStr = [NSString stringWithFormat:@"￥%ld.0",moneyInt];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:moneStr];
        
        [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, 1)];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:35.0] range:NSMakeRange(1,1+colorRange)];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:20.0] range:NSMakeRange(2+colorRange,1)];
        self.moneyLable.attributedText = str;
        self.moneyLable.hidden = NO;
    }
    self.titleLable.text = redpackModel.redpackname;
    self.timeLable.text = [NSString stringWithFormat:@"有效期%@至%@",ctimeStr,etimeStr];

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    if (self.isshow == YES) {
        if (selected) {
            self.selectImgView.hidden = NO;
            [self.selectImgView setImage:[UIImage imageNamed:@"me_red_select"]];
        } else {
            self.selectImgView.hidden = YES;
        }
    }else{
        self.selectImgView.hidden = YES;
    }
    

    // Configure the view for the selected state
}

@end
